package com.shanling.shanlingcontroller.persenter

import com.shanling.shanlingcontroller.music.player.SongLoader
import com.shanling.shanlingcontroller.persenter.contract.AlbumFragmentConttact
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread


/**
 * Created by ch1 on 2019/11/22.
 */
class AlbumFragmentPersenter  constructor() : RxPresenter<AlbumFragmentConttact.View>(), AlbumFragmentConttact.Presenter {
    override fun loadAlbums(action: String) {
        mView?.showLoading()
        doAsync {
            val data = SongLoader.getAllAlbums()
            uiThread {
                mView?.hideLoading()
                if(data.size==0){
                    mView?.setEmptyView()
                }else{
                    mView?.showAlbums(data)
                }
            }
        }
    }

}